layui.use(['table', 'admin', 'ax', 'func'], function () {
    var $ = layui.$;
    var table = layui.table;
    var $ax = layui.ax;
    var admin = layui.admin;
    var func = layui.func;

    /**
     * 数据清洗表详情管理
     */
    var CleanDetail = {
        tableId: "cleanDetailTable"
    };

    /**
     * 初始化表格的列
     */
    CleanDetail.initColumn = function () {
        return [[
            {type: 'checkbox', hide: true},
            {field: 'dataCleanDetailId', hide: true, title: '数据清洗详情id'},
            {field: 'dataDataCleanId', sort: false, title: '关联清洗表', hide: true},
            {field: 'problemColumnName', sort: false, title: '问题字段', align: "center"},
            {field: 'problemColumnDetail', sort: false, title: '问题字段数据', align: "center"},
            {field: 'isDelete', sort: false, title: '是否删除；0代表删除；1代表可用', hide: true},
            {align: 'center', toolbar: '#tableBar', title: '操作', hide: true}
        ]];
    };

    $("#returnBefore").click(function () {
        history.go(-1)
    })

    $("#reset").click(function () {
        $("#problemColumnName").val("")
        CleanDetail.search()
    })

    /**
     * 点击查询按钮
     */
    CleanDetail.search = function () {
        var queryData = {};

        queryData['problemColumnName'] = $('#problemColumnName').val();

        table.reload(CleanDetail.tableId, {
            where: queryData, page: {curr: 1}
        });
    };

    // 渲染表格
    var tableResult = table.render({
        elem: '#' + CleanDetail.tableId,
        url: Feng.ctxPath + '/cleanDetail/list?dataDataCleanId=' + Feng.getUrlParam("dataDataCleanId"),
        page: true,
        height: "full-158",
        cellMinWidth: 100,
        skin: "line",
        cols: CleanDetail.initColumn(),
        done: function (res, curr, count) {
            $('tr').css('background-color', '#ffffff')
        }
    });

    // 搜索按钮点击事件
    $('#btnSearch').click(function () {
        CleanDetail.search();
    });


    // 工具条点击事件
    table.on('tool(' + CleanDetail.tableId + ')', function (obj) {
        var data = obj.data;
        var layEvent = obj.event;

        if (layEvent === 'edit') {
            CleanDetail.openEditDlg(data);
        } else if (layEvent === 'delete') {
            CleanDetail.onDeleteItem(data);
        }
    });
});
